<template>
	<nav-header title="表单列表">
        <my-page ref="mypage" v-model="formList" @load-data="loadData">
            <template slot="content">
                <view v-for="item in formList" :key="item.id" @click="openDetail(item)" 
					class="relative bg-white m-4 p-4 last:mb-0 shadow-lg rounded-xl  active:bg-gray-100 flex">
					<u-image height="5.6rem" width="6.1rem" radius="8"
						:src="item.iconUrl? $util.formatImageIdUrl(item.iconUrl):flowDefaultIcon">
						 <image slot="error" :src="flowDefaultIcon"></image>
					</u-image>
                    <view class="flex-1 pl-3 flex flex-col">
                        <view class="flex-1">
                            <view>{{item.name}}</view>
                            <view class="text-gray-500 text-sm py-0_5">
                                {{item.typeName}}
                            </view>
                        </view>
                        <view class="text-gray-500 text-sm flex">
                            <view class="flex-1" v-text="$util.getFormatDate(item.updateTime, 'yyyy-0m-0d')"></view>
                            <view class="text-color-theme">创建表单</view>
                        </view>
                    </view>
                </view>
            </template>
        </my-page>
    </nav-header>
</template>
<script>
import MyPage from '@/components/my_page.vue'
import NavHeader from '@/components/nav_header.vue'
import {getPublicFormList} from '@/interface/junchuang/form.js'
import MescrollPageMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-page.js"
export default {
	name: 'FormList',
	mixins: [MescrollPageMixin],
    components: { NavHeader, MyPage },
    data(){
        return {
            params: {},
            formList: [],
            flowDefaultIcon: require('./static/flow-default.png'),
        }
    },
    methods:{
        loadData(page, success, error){
            Object.assign(this.params, page);
            getPublicFormList(this.params).then(res=>{
                success(res)
            }).catch(err=>{
                error(err);
            });
        },
        openDetail(item){
            this.$util.myNavigateTo('/pages_form/detail/index?formCode='+item.formCode);
        },
        html2Text(htmlTxt){
            if (this.$utils.isBlank(htmlTxt)) return "";
            var reg = new RegExp("<.+?>","g");//匹配html标签的正则表达式，"g"是搜索匹配多个符合的内容
            var text = htmlTxt.replace(reg, "");//执行替换成空字符
            return text;
        }
    }
}
</script>